<template>
	<view>
		<button @click="onSingleTimeOut()" type="primary">单次计时器</button>
		<button @click="onSetTimeOut('hhl',4)" type="primary" plain="true">启动传参计时器</button><!-- 同步接口 -->
		<button @click="onClearTimeOut()" type="warn">取消计时器</button>
		<!-- 周期计时器隔时间运行一次 -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'hhl',
				timer:null
			}
		},
		methods: {
			onSingleTimeOut(){
				setTimeout(()=>{
					console.log("onSingleTimeOut() callback");
					console.log("onSingleTimeOut() callback end");
				},3000);
			},
			onSetTimeOut(username,pwd){
				console.log("onSetTimeOut()",username,pwd);
				setTimeout((a,b)=>{
					console.log("---callback",a,b);
				},2000,username,pwd)
			},
			onClearTimeOut(){
				console.error("onClearTimeOut() 取消");
				clearTimeout(this.timer);
			}
		}
	}
</script>

<style>
button{
	margin: 15rpx;
}
</style>
